package lt.marsrutai.mobile.android.util;

import java.io.IOException;
import java.io.Serializable;

import android.util.Log;

public class Base64Utils {
    
    private static String TAG = "Base64Utils";

    public static String deflate(Object object) {
        try {
            return Base64.encodeObject((Serializable) object);
        }
        catch (IOException e) {
            Log.e(TAG, e.getMessage());
        }

        return null;
    }

    @SuppressWarnings("unchecked")
    public static <T> T inflate(String string) {
        try {
            return (T) Base64.decodeToObject(string);
        }
        catch (IOException e) {
            Log.e(TAG, e.getMessage());
        }
        catch (ClassNotFoundException e) {
            Log.e(TAG, e.getMessage());
        }

        return null;
    }
}
